<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>用户信息设置</title>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
    <link rel="stylesheet" href="../js/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="../style/admin.css" media="all"/>
    <link rel="stylesheet" href="../style/home.css" media="all"/>
    <script src="../js/layui/layui.js"></script>
    <style>
        .layui-form-item .layui-inline {
            padding-right: 0px;
            margin-right: 0px;
        }

        .layui-form-item span {
            color: #555;
        }
    </style>
</head>
<body layadmin-themealias="default">
<div class="" style="padding: 20px">
    <div class="layui-row layui-col-space15">
        <div class="layui-card pr20" style="height: 400px">
            <form class="layui-form" lay-filter="postData" action="" id="postData">
                <input type="hidden" name="parentId" th:value="${data.parentId}"/>
                <input type="hidden" name="classCode" th:value="${data.classCode}"/>
                <input type="hidden" name="pcode" th:value="${data.pcode}"/>
                <input type="hidden" name="id" th:value="${data.id}"/>
                <th:block th:if="${data.parentId != '0'}">
                    <input type="hidden" name="idx" value="999999"/>
                </th:block>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">分类号</label>
                        <div class="layui-inline">
                            <div class="layui-input-inline" style="width: 60px; margin-right: 0px;">
                                <input type="text" name="pcodeinput" autocomplete="off" class="layui-input" disabled=""
                                       th:value="${data.pcode}"/>
                            </div>
                            <div class="layui-input-inline" style="width: 55px ; margin-right: 0px;">
                                <select name="doc" lay-search="">
                                    <option th:selected="''==${data.doc}" value="">无</option>
                                    <option th:selected="'-'==${data.doc}" value="-">-</option>
                                    <option th:selected="'·'==${data.doc}" value="·">·</option>
                                </select>
                            </div>
                            <div class="layui-input-inline" style="width: 60px">
                                <input type="text" name="code" autocomplete="off"
                                       th:th:attr="${data.parentId == '0'} ? 'lay-verify=required' : null"
                                       class="layui-input" th:value="${data.code}"/>
                            </div>
                        </div>
                    </div>
                    <th:block th:if="${data.parentId == '0'}">
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 60px">顺序号</label>
                            <div class="layui-inline" style="margin-right: 0px;">
                                <div class="layui-input-inline" style="width: 60px">
                                    <input type="text" name="idx" autocomplete="off" class="layui-input"
                                           th:value="${data.idx}"/>
                                </div>

                            </div>
                        </div>
                    </th:block>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">档案门类</label>
                    <div class="layui-input-block">
                        <select name="classifyId" lay-search="">
                            <option value="">直接选择或搜索选择</option>
                            <option th:selected="${option.id eq data.classifyId}"
                                    th:each="option : ${classifyList}"
                                    th:value="${option.id}" th:text="${option.classifyName}"></option>
                        </select>
                    </div>

                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">分类名称</label>
                    <div class="layui-input-block">
                        <input
                                type="text"
                                name="name"
                                placeholder="请输入分类名称"
                                autocomplete="off"
                                class="layui-input"
                                required
                                lay-verify="required"
                                th:value="${data.name}"
                        />
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">描述</label>
                    <div class="layui-input-block">
                        <textarea name="remark" placeholder="请输入内容" class="layui-textarea"
                                  th:text="${data.remark}"></textarea>
                    </div>
                </div>
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="postData" id="postBut"
                        style="display: none">立即提交
                </button>
            </form>
        </div>
    </div>
</div>
<script>
    var form = layui.form;
    var $ = layui.$;
    var callBackReturn = false,
        tree = layui.tree;
    var index = parent.layer.getFrameIndex(window.name);

    form.render();


    $('.downpanel')
        .on('click', '.layui-select-title', function (e) {
            $('.layui-form-select')
                .not($(this).parents('.layui-form-select '))
                .removeClass('layui-form-selected');
            $(this).parents('.downpanel').toggleClass('layui-form-selected');
            layui.stope(e);
        })
        .on('click', 'dl i', function (e) {
            layui.stope(e);
        });

    form.on("submit(postData)", function (obj) {
        var data = obj.field;
        $.ajax({
            url: "./saveArchivesClass", //url
            contentType: "application/json",
            dataType: "json", //数据格式
            type: "POST", //请求方式
            async: false, //是否异步请求
            data: JSON.stringify(data),
            success: function (result) {
                if (result.code == 0) {
                    parent.layer.msg(result.message, {icon: 1});
                    callBackReturn = true;
                    parent.layer.close(index);
                } else {
                    parent.layer.alert(result.message, {icon: 2});
                }
            },
        });
        return false;
    });

    function Buttun_Submit() {
        document.getElementById("postBut").click();
        return callBackReturn;
    }
</script>
<script type="text/javascript" src="../js/lib/watermark.js"></script>
</body>
</html>
